package com.freemyleft.left.left_app.mian.index.work;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.freemyleft.left.left_app.R;
import com.freemyleft.left.left_app.R2;
import com.freemyleft.left.left_app.mian.index.my.accept_setup.AcceptOrderSetupDelegate;
import com.freemyleft.left.left_app.mian.index.work.adapter.WorkPageAdapter;
import com.freemyleft.left.left_app.mian.index.work.allcourses.AllCoursesDelegate;
import com.freemyleft.left.left_app.mian.index.work.completecoures.CompleteCourseDelegate;
import com.freemyleft.left.left_app.mian.index.work.roborder.RobOrderDelegate;
import com.freemyleft.left.left_app.mian.index.work.waitingforclass.WaitingForClassDelegate;
import com.freemyleft.left.zapp.delegates.Bottom.BottomItemDelegate;
import com.freemyleft.left.zapp.delegates.LeftDelegate;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

public class WorkDelegate extends BottomItemDelegate {
    @BindView(R2.id.work_tablayout)
    TabLayout tabLayout;
    @BindView(R2.id.work_viewpager)
    ViewPager mPager;
    @BindView(R2.id.tv_schedule)
    TextView schedule;
    @OnClick(R2.id.tv_roborder)
    void onClickorder(){
        getParentDelegate().start(new AcceptOrderSetupDelegate());

    }
    @OnClick(R2.id.tv_schedule)
    void onClicksSchedule (){
        getParentDelegate().start(new AllCoursesDelegate());

    }
    WorkPageAdapter adapter;
    private ArrayList<LeftDelegate> DELEGEDE = new ArrayList<>();

    private ArrayList<String> mTitle = new ArrayList<>();

    @Override
    public Object setLayout() {
        return R.layout.delegate_work;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {
        initData();

    }
    private void initData() {
        mTitle.add("待上课");
        mTitle.add("已上课");
        mTitle.add("抢单");
        DELEGEDE.add(new WaitingForClassDelegate());
        DELEGEDE.add(new CompleteCourseDelegate());
        DELEGEDE.add(new RobOrderDelegate());
        adapter = new WorkPageAdapter(getChildFragmentManager(), mTitle, DELEGEDE);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        mPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(mPager);

    }
}
